package commonutils;

import java.util.Random;

public class StringUtils {
    
    
    public static boolean isNotBlank(String str){
	return org.apache.commons.lang3.StringUtils.isNotBlank(str);
    }
    
    /**
      StringUtils.isBlank(null) = true
      StringUtils.isBlank("") = true
      StringUtils.isBlank(" ") = true
      StringUtils.isBlank("        ") = true
      StringUtils.isBlank("\t \n \f \r") = true   //对于制表符、换行符、换页符和回车符
      StringUtils.isBlank()   //均识为空白符
      StringUtils.isBlank("\b") = false   //"\b"为单词边界符
      StringUtils.isBlank("bob") = false
      StringUtils.isBlank(" bob ") = false
     * @param str
     * @return
     */
    public static boolean isBlank(String str){
	return org.apache.commons.lang3.StringUtils.isBlank(str);
    }

    /**
     * 获取一定长度的随机字符串
     * @param length 指定字符串长度
     * @return 一定长度的字符串
     */
    public static String getRandomStringByLength(int length) {
        String base = "abcdefghijklmnopqrstuvwxyz0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }
        return sb.toString();
    }

}
